<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: LayerTree</title>

<!--
    <script src="http://shjs.sourceforge.net/sh_main.min.js"> </script>
    <script src="http://shjs.sourceforge.net/lang/sh_javascript.min.js"> </script>
-->
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/node-dark.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Class: LayerTree</h1>
    
    



<section>
    
<header>
    <h2>
        <span class="ancestors"><a href="module-layers.html">layers</a>.</span>
    
    LayerTree
    </h2>
    
</header>  

<article>
    <div class="container-overview">
    
    
    
        
<dt>
    <h4 class="name" id="LayerTree"><span class="type-signature"></span>new LayerTree</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Constructor for a <code>LayerTree</code> object that holds information about the
current state of all the layers in the current document.  To use it,
just create a new instance:</p>

<pre><code>var tree = new layers.LayerTree();
// shows index of layer named "Dialog"
alert(tree.layer("Dialog").index);
</code></pre>

<p>The <code>LayerTree</code> is generated for the layers on the current frame of the
document.  Change <code>dom.currentFrameNum</code> before creating a new <code>LayerTree</code>
to get the layers on a different frame.  Due to bugs in the layers API,
if you change <code>dom.currentFrameNum</code> <em>after</em> creating the <code>LayerTree</code>, the
wrong layer is likely to be returned or modified when accessing a layer
by name or index.</p>

<p>The <code>LayerTree</code> members return instances of the <a href="module-layers.Layer.html">module:layers.Layer</a>
class.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inDOM</code></td>
            
            
            <td class="type">
            
                        Object
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    currentDOM
                
                </td>
            
            
            <td class="description last"><p>An optional reference to an open
Fireworks document.  If not provided, the <code>LayerTree</code> will default
to the current document.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inIgnoreWebLayers</code></td>
            
            
            <td class="type">
            
                        Boolean
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    false
                
                </td>
            
            
            <td class="description last"><p>Pass true to create a <code>LayerTree</code>
that does not include any <code>Layer</code> instances for the web layers in
the document, which makes looping over the layers a little simpler
if you want to ignore slices and hotspots.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 124</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>A <code>LayerTree</code> instance representing the layers in the
current document.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Object</span> 
		
	</dd>
</dl>

        
    
    
</dd>

    
    </div>
    
    
    
    
    
    
    
    
    
    
    
    
        <h3 class="subsection-title">Members</h3>
        
        <dl>
            
<dt>
    <h4 class="name" id="currentLayer"><span class="type-signature"></span>currentLayer<span class="type-signature"> :Layer</span></h4>
    
    
</dt>
<dd>
    
    <div class="description">
        <p>The current <code>Layer</code> of the document.  Set this to the index or name
of a layer, or to a <code>Layer</code> instance, to set the document's
<code>currentLayerNum</code> value.</p>
    </div>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 270</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
</dd>

        
            
<dt>
    <h4 class="name" id="currentTopLayer"><span class="type-signature"></span>currentTopLayer<span class="type-signature"> :Layer</span></h4>
    
    
</dt>
<dd>
    
    <div class="description">
        <p>The top-level <code>Layer</code> object that contains the current layer of the
document.  Set this to the index or name of a layer, or to a <code>Layer</code>
instance, to set the document's <code>currentLayerNum</code> value to that
layer's top-level ancestor.</p>
    </div>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 300</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
</dd>

        
            
<dt>
    <h4 class="name" id="layers"><span class="type-signature"></span>layers<span class="type-signature"> :[Layer]</span></h4>
    
    
</dt>
<dd>
    
    <div class="description">
        <p>An array of <code>Layer</code> instances representing all of the layers in the
document.</p>

<p>Note that this getter returns a copy of the layers array every time
it's accessed, so if you need just one layer, it's a little more
efficient to call the <code>layer()</code> method.</p>
    </div>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 211</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
</dd>

        
            
<dt>
    <h4 class="name" id="topLayers"><span class="type-signature"></span>topLayers<span class="type-signature"> :[Layer]</span></h4>
    
    
</dt>
<dd>
    
    <div class="description">
        <p>An array of the top <code>Layer</code> instances in the document.</p>
    </div>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 223</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
</dd>

        
            
<dt>
    <h4 class="name" id="webLayer"><span class="type-signature"></span>webLayer<span class="type-signature"> :Layer</span></h4>
    
    
</dt>
<dd>
    
    <div class="description">
        <p>A <code>Layer</code> instance representing the top-most web layer.</p>
    </div>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 235</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
</dd>

        
            
<dt>
    <h4 class="name" id="webLayers"><span class="type-signature"></span>webLayers<span class="type-signature"> :[Layer]</span></h4>
    
    
</dt>
<dd>
    
    <div class="description">
        <p>An array of the <code>Layer</code> instances representing the web layers in
the document.</p>
    </div>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 252</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
</dd>

        </dl>
    
    
    
        <h3 class="subsection-title">Methods</h3>
        
        <dl>
            
<dt>
    <h4 class="name" id="getContainingLayer"><span class="type-signature"></span>getContainingLayer</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns a <code>Layer</code> instance that contains the element.</p>

<p>Note that if you alt-drag an element to a different layer, and
then pass that duplicate to this method to find the layer it's on,
the wrong one may be returned.  That is because when the element is
duplicated, both the original and the duplicate share a single
<code>customData</code> object, and this method compares <code>customData</code> objects
to try to find the element you pass in.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inElement</code></td>
            
            
            <td class="type">
            
                        Object
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The element to look for in the current
document's layers.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 353</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>A <code>Layer</code> instance that contains the element as an
immediate child, or <code>undefined</code> if it can't be found.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Layer</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="layer"><span class="type-signature"></span>layer</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns a <code>Layer</code> instance accessed by its index in the layer stack
or by its name.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inIndex</code></td>
            
            
            <td class="type">
            
                        Number
                         | 
                    
                        String
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The 0-based index or name of a layer.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 330</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>A <code>Layer</code> instance representing the specified
layer, or <code>undefined</code> if it can't be found.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Layer</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="refresh"><span class="type-signature"></span>refresh</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Updates the <code>LayerTree</code>'s internal data to reflect the current
state of the document and sets any existing <code>Layer</code> instances
associated with this tree to a stale state.  This method should be
called whenever a layer is deleted or rearranged in the stack,
which can cause one or more of the layers' indexes to change.</p>

<p>Instead of calling <code>refresh()</code>, you can also just create a new
<code>LayerTree</code> instance, which will reflect the current state of the
document.</p>
    </div>
    
    
    
    
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 155</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    
    
</dd>

        </dl>
    
    
    
    
    
</article>

</section>  




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-DomStorage.html">DomStorage</a></li><li><a href="module-files.html">files</a></li><li><a href="module-fonts.html">fonts</a></li><li><a href="module-layers.html">layers</a></li><li><a href="module-prefs.html">prefs</a></li><li><a href="module-underscore.html">underscore</a></li></ul><h3>Classes</h3><ul><li><a href="a321565296.html">DomStorage</a></li><li><a href="module-layers.Layer.html">Layer</a></li><li><a href="module-layers.LayerTree.html">LayerTree</a></li><li><a href="module-prefs.PrefsStorage.html">PrefsStorage</a></li><li><a href="_.html">_</a></li></ul>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3</a> on Mon Jul 08 2013 09:13:10 GMT-0700 (PDT)
</footer>

<script> sh_highlightDocument(); </script>
</body>
</html>
